class code1 {
    //二分
    public int[] twoSum(int[] numbers, int target) {
        int[] ret = new int[2];

        for(int i=0;i<numbers.length;i++) {
            int x = target-numbers[i];
            int l = i+1;
            int r = numbers.length-1;
            while(l < r) {
                int mid = l + (r-l+1)/2;
                if(numbers[mid] > x) {
                    r = mid - 1;
                } else {
                    l = mid;
                }
            }
            if(numbers[l] == x) {
                //注意下标从1开始
                ret[0] = i+1;
                ret[1] = l+1;
                return ret;
            }
        }
        return ret;
    }
}